package springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lingpeng.jiang
 * @create 2021-01-22-20:53
 */
@RestController
@EnableBinding(Sink.class)
public class MessageConsumerController {


    @Value("${server.port}")
    private String serverPort;


    @StreamListener(Sink.INPUT)
    public void receiveMessage(Message<String> message){
        System.out.println("接受到了消息，内容为------> " + message.getPayload() + "\t serverPort: " + serverPort);
    }
}
